package my.edu.model.bills.sales.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import my.edu.common.domain.OrderProductDetail;
import my.edu.common.enumeration.OrderType;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("sales_order_detail")
public class SalesOrderDetail extends OrderProductDetail {
    @TableId(type = IdType.AUTO)
    private Long id;
    private Long salesOrderId;
    private Long warehouseId;
    private String warehouseName;
    //private Integer wholePackage;
    private BigDecimal conversionRate;//换算率
    //private BigDecimal basicQuantity;
    private BigDecimal salesPrice;
//    private BigDecimal referenceCost;
//    private BigDecimal estimatedGrossProfit;
//    private BigDecimal estimatedGrossProfitRate;
    private BigDecimal lastPurchasePrice;
    private String remark;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;
    @TableField(fill = FieldFill.UPDATE)
    private Long updatedBy;

    @Override
    public BigDecimal getCurrentPrice() {
        return getSalesPrice();
    }

    @Override
    public void setCurrentPrice(BigDecimal price) {
        setSalesPrice(price);
    }

    @Override
    public OrderType getCurrentOrderType() {
        return OrderType.SALE_PRICE;
    }
}
